﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AAA.Writer
{
    public abstract class AbstractWriter : IWriter
    {
        private Dictionary<string, object> _dicValue;
        private string _strSourceFile;
        private string _strTargetFile;
        private bool _isAppend;
        private string _strErrorMessage;

        public AbstractWriter()
        {
            _dicValue = new Dictionary<string, object>();
        }

        #region IWriter Members
        public string SourceFile 
        {
            get { return _strSourceFile; }
            set { _strSourceFile = value; }
        }
        public string TargetFile 
        {
            get { return _strTargetFile; }
            set { _strTargetFile = value; }
        }

        public bool IsAppend
        {
            get { return _isAppend; }
            set { _isAppend = value; }
        }

        public string ErrorMessage
        {
            get { return _strErrorMessage; }
            set { _strErrorMessage = value; }
        }

        public void Value(string strKey, object oValue)
        {
            if(_dicValue.ContainsKey(strKey))
                _dicValue[strKey] = oValue;
            else
                _dicValue.Add(strKey, oValue);
        }

        public object Value(string strKey)
        {
            return _dicValue.ContainsKey(strKey) ? _dicValue[strKey] : null;
        }

        public abstract bool Write(AAA.ResultSet.IResultSet resultSet, object oFormat);
        public abstract bool Write(Dictionary<string, CellValue> dicValue, object oFormat);
        #endregion
    }
}
